using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using SFS.SampleApp.Web.Mvc.Resources;
using System.Runtime.Serialization;
using SFSdotNet.Framework.Web.Mvc.Models;
using SFSdotNet.Framework.Web.Mvc.Extensions;
using BO = SFS.SampleApp.BusinessObjects;
using System.Web.Mvc;
using SFSdotNet.Framework.Web.Mvc.Validation;
using SFSdotNet.Framework.Web.Mvc.Models;
using SFSdotNet.Framework.Web.Mvc.Resources;
using SFSdotNet.Framework.Entities.Metadata;


namespace SFS.SampleApp.Web.Mvc.Models.ProductModelProductDescriptions 
{
	public partial class ProductModelProductDescriptionModel: ModelBase{
		public ProductModelProductDescriptionModel()
        {
		}
		public override string Id
        {
            get
            {
                return this.ProductModelID.ToString();
            }
        }
			
			
        public override string ToString()
        {
		
            return this.ProductModelID.ToString();
		
        }    
			
	
		[SystemProperty()]		
		public Int32? ProductModelID{ get; set; }
		
	
		[SystemProperty()]		
		public Int32? ProductDescriptionID{ get; set; }
		
	
		[SystemProperty()]		
		public String Culture{ get; set; }
		
	
[Exportable()]
		
	[RelationFilterable()]
	[SystemProperty()]
	[LocalizedDisplayName("ROWGUID", NameResourceType=typeof(ProductModelProductDescriptionResources))]
	public Guid   rowguid { get; set; }
		
		
	
[Exportable()]
	
	    [Required(AllowEmptyStrings=false, ErrorMessageResourceName="VAL_MODIFIEDDATE_REQUIRED", ErrorMessageResourceType=typeof(ProductModelProductDescriptionResources))]
		
	[RelationFilterable()]
	[DateTime(true, false, null)]	
	[LocalizedDisplayName("MODIFIEDDATE", NameResourceType=typeof(ProductModelProductDescriptionResources))]
	public DateTime   ModifiedDate { get; set; }
	public string ModifiedDateText {
        get {
            if (ModifiedDate != null)
			
                return ((DateTime)ModifiedDate).ToShortDateString();
            else
                return String.Empty;
        }
				set{
				this.ModifiedDate = Convert.ToDateTime(value);
    }
		}
		
		
	
[Exportable()]
		
	[RelationFilterable(DataClassProvider = typeof(Controllers.ProductDescriptionsController), GetByKeyMethod="GetByKey", GetAllMethod = "GetAll", DataPropertyText = "Description", DataPropertyValue = "ProductDescriptionID", FiltrablePropertyPathName="ProductDescription.ProductDescriptionID")]	

	[LocalizedDisplayName("PRODUCTDESCRIPTION", NameResourceType=typeof(ProductModelProductDescriptionResources))]
	public Int32  ? FkProductDescription { get; set; }
		[LocalizedDisplayName("PRODUCTDESCRIPTION", NameResourceType=typeof(ProductModelProductDescriptionResources))]
	[Exportable()]
	public string  FkProductDescriptionText { get; set; }
    public string FKProductDescriptionSafeKey { get; set; }

	
		
	
[Exportable()]
		
	[RelationFilterable(DataClassProvider = typeof(Controllers.ProductModelsController), GetByKeyMethod="GetByKey", GetAllMethod = "GetAll", DataPropertyText = "Name", DataPropertyValue = "ProductModelID", FiltrablePropertyPathName="ProductModel.ProductModelID")]	

	[LocalizedDisplayName("PRODUCTMODEL", NameResourceType=typeof(ProductModelProductDescriptionResources))]
	public Int32  ? FkProductModel { get; set; }
		[LocalizedDisplayName("PRODUCTMODEL", NameResourceType=typeof(ProductModelProductDescriptionResources))]
	[Exportable()]
	public string  FkProductModelText { get; set; }
    public string FKProductModelSafeKey { get; set; }

	
		
		
	public override string SafeKey
   	{
		get
        {
			if(this.ProductModelID != null && this.ProductDescriptionID != null && this.Culture != null)
				return SFSdotNet.Framework.Entities.Utils.GetKey(this ,"ProductModelID", "ProductDescriptionID", "Culture").Replace("/","-");
			else
				return String.Empty;
		}
    }		
		public void Bind(ProductModelProductDescriptionModel model){
            
		this.ProductModelID = model.ProductModelID;
		this.ProductDescriptionID = model.ProductDescriptionID;
		this.Culture = model.Culture;
		this.rowguid = model.rowguid;
		this.ModifiedDate = model.ModifiedDate;
        }

        public BusinessObjects.ProductModelProductDescription GetBusinessObject()
        {
            BusinessObjects.ProductModelProductDescription result = new BusinessObjects.ProductModelProductDescription();
	if (this.ProductModelID != null )
				result.ProductModelID = (Int32)this.ProductModelID;
				
	if (this.ProductDescriptionID != null )
				result.ProductDescriptionID = (Int32)this.ProductDescriptionID;
				
	if (this.Culture != null )
				result.Culture = (String)this.Culture.Trim().Replace("\t", String.Empty);
				
	if (this.rowguid != null )
				result.rowguid = (Guid)this.rowguid;
				
				result.ModifiedDate = (DateTime)this.ModifiedDate;		
				
	result.ProductDescription = new BusinessObjects.ProductDescription() { ProductDescriptionID= (Int32)this.FkProductDescription };
				
	result.ProductModel = new BusinessObjects.ProductModel() { ProductModelID= (Int32)this.FkProductModel };
				



            return result;
        }
        public void Bind(BusinessObjects.ProductModelProductDescription businessObject)
        {
            
			this.ProductModelID = businessObject.ProductModelID;
				
			this.ProductDescriptionID = businessObject.ProductDescriptionID;
				
			this.Culture = businessObject.Culture != null ? businessObject.Culture.Trim().Replace("\t", String.Empty) : "";
				
			this.rowguid = businessObject.rowguid;
				
				this.ModifiedDate = (DateTime)businessObject.ModifiedDate;
	        if (businessObject.ProductDescription != null){
	                	this.FkProductDescriptionText = businessObject.ProductDescription.Description.Trim().Replace("\t", String.Empty); 
										
										
				this.FkProductDescription = businessObject.ProductDescription.ProductDescriptionID;
                this.FKProductDescriptionSafeKey  = SFSdotNet.Framework.Entities.Utils.GetKey(businessObject.ProductDescription,"ProductDescriptionID").Replace("/","-");

			}
	        if (businessObject.ProductModel != null){
	                	this.FkProductModelText = businessObject.ProductModel.Name.Trim().Replace("\t", String.Empty); 
										
										
				this.FkProductModel = businessObject.ProductModel.ProductModelID;
                this.FKProductModelSafeKey  = SFSdotNet.Framework.Entities.Utils.GetKey(businessObject.ProductModel,"ProductModelID").Replace("/","-");

			}
           
        }
	}
}
